﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cinchoo.Core;
using System.ComponentModel;
using Cinchoo.Core.Net.Sockets;
using System.Threading.Tasks;
using System.Threading;
using ChoWorkflowServer.Model;
using System.Data.SqlClient;
using System.Net.Sockets;
using System.Net;
using Cinchoo.Core.Diagnostics;
using Cinchoo.Core.ETL;
using System.Reflection;
using System.Diagnostics;
using Cinchoo.Core.IO;
using Cinchoo.Core.Net;
using Cinchoo.Core.Shell;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.IO;
using Cinchoo.Core.Threading.Tasks;
using Cinchoo.Core.Reflection;
using Cinchoo.Core.Compiler;

namespace ChoWorkflowServer
{
    public partial class Program
    {
        [STAThread]
        private static void Main(string[] args)
        {
            ChoCodeBaseSettings.Me.IncludeAppBaseSubDirectories = false;
            ChoAssemblySettings.Me.AddExcludeAssemblyWildCard("*PlugIns*");

            ChoWFServerCmdLineArgsObject cmdArgs = new ChoWFServerCmdLineArgsObject();
            if (cmdArgs.Refresh)
            {
                ChoConsole.Write("Are you sure want to refresh internal database (Y/N)? -> ");
                if (ChoConsole.ReadLine(10000, "N").ToUpper() == "Y")
                {
                    ChoConsole.WriteLine("Refreshing internal database...");
                    IChoDataModel _dataModel = ChoDataModelFactory.New();
                    _dataModel.RefreshDB();
                    ChoConsole.WriteLine("Refreshing internal database completed.");
                    return;
                }
                else
                    return;
            }

            ChoWorkflowServerEx wfServer = new ChoWorkflowServerEx();
            wfServer.Run(args);
        }
    }
}
